package com.esbi.projectwebsocket.interceptor;

import com.esbi.projectwebsocket.jwt.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("【配置类】正在注册拦截器...");
        // 注册 JWT 拦截器，并指定拦截的路径模式为所有路径
        registry.addInterceptor(new JwtInterceptor()).addPathPatterns("/eeeee");
        // 注册 CustomInterceptor 拦截器，并指定拦截的路径模式为所有路径
        registry.addInterceptor(new CustomInterceptor()).addPathPatterns("/eeee");
      /*  // 注册 JWT 拦截器，仅拦截特定路径，如以 /auth/ 开头的路径
        registry.addInterceptor(new JwtInterceptor()).addPathPatterns("/auth/**");
        // 注册 CustomInterceptor，拦截特定路径，如以 /custom/ 开头的路径
        registry.addInterceptor(new CustomInterceptor()).addPathPatterns("/custom/**");*/
        System.out.println("【配置类】拦截器注册完成。");
    }
}